<?php if(!defined('BASEPATH'))exit('No direct script allowed');
class Page extends AppController
{
	
	public function __construct()
	{
		parent::__construct();

	}
	
	public function index(){
		$this->data['new_product'] = $this->getEM()->getRepository('Entity\ShProduct')->findBy(
			array('status' => 1),array('id' => 'DESC'), 10,0
		);
		
		$this->data['most_wanted'] = $this->getEM()->getRepository('Entity\ShProduct')->findMostWanted();
		$this->data['special'] = $this->getEM()->getRepository('Entity\ShProduct')->findBy(array(
			'status' => 1,
		), array('price' => 'DESC'), 8);
		$this->render('page/index', array(), array(
			'/assets/css/frontend/pages/style-shop.css',
			'/assets/css/frontend/pages/style-layer-slider.css'
		));
	}

	public function about(){

		$this->render('page/about');
	}

	public function contact(){
		$this->render('page/contact');
	}

	public function admin_index()
	{

		//$this->log(2, array('1', 'Admin', 'áo ấm', '567'));
		$this->data['user'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllUser();
		$this->data['cnews'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllNews();
		$this->data['sale'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllSale();
		$this->data['product'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllProduct();
		$this->data['image'] =  $this->getEM()->getRepository('Entity\ShConfig')->countAllImage();
		$this->data['stick'] = $this->getEM()->getRepository('Entity\ShConfig')->countStickyNews();
		$this->data['log'] = $this->getEM()->getRepository('Entity\ShLog')->findBy(array(),array(
			'object' => 'desc',
			'id' => 'desc'
		),5);
		$this->data['logconfig'] = $this->log_config;
		
		
		$this->data['statistic'] = array(
			'website' =>$this->getEM()->getRepository('Entity\ShConfig')->website()
			);
		$this->render('page/admin_index');
	}
	public function mod_index(){
		$this->data['user'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllUser();
		$this->data['cnews'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllNews();
		$this->data['sale'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllSale();
		$this->data['product'] = $this->getEM()->getRepository('Entity\ShConfig')->countAllProduct();
		$this->data['image'] =  $this->getEM()->getRepository('Entity\ShConfig')->countAllImage();
		$this->data['stick'] = $this->getEM()->getRepository('Entity\ShConfig')->countStickyNews();
		$this->data['statistic'] = array(
			'website' =>$this->getEM()->getRepository('Entity\ShConfig')->website()
			);
		$this->render('page/mod_index');
	}
	public function admin_logout(){
		$this->session->sess_destroy();
		redirect('/');
	}
	public function mod_logout(){
		$this->session->sess_destroy();
		redirect('/');
	}
}
?>